/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : structs_internal
	/// </summary>
	public class GmMailPOD : IPOD 
    {
        public readonly static Func<GmMailPOD> FACTORY = () => new GmMailPOD();
		public static Func<GmMailPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public int id;
		/// <summary>
        ///  标题
        /// </summary>
		public string title;
		/// <summary>
        ///  内容
        /// </summary>
		public string content;
		/// <summary>
        ///  发送者
        /// </summary>
		public string sender;
		/// <summary>
        ///  发送时间	(时间戳)
        /// </summary>
		public long createTime;
		/// <summary>
        ///  结束时间
        /// </summary>
		public long endTime;
		/// <summary>
        ///  附件列表
        /// </summary>
        private List<int> m_itemList;
		/// <summary>
        ///  是否是全服邮件
        /// </summary>
		public bool isAllPlayer;
		/// <summary>
        ///  是否是全时段邮件
        /// </summary>
		public bool isAllTime;
		/// <summary>
        ///  目标
        /// </summary>
        private List<long> m_target;
		/// <summary>
        ///  等级限制
        /// </summary>
		public int levelLimit;
		/// <summary>
        ///  付费代币
        /// </summary>
		public int payPoint;
		/// <summary>
        ///  专属渠道
        /// </summary>
		public string channelIds;
		
		
        public List<int> itemList
        {
            get
            {
                if(m_itemList == null)
                {
                    m_itemList = new();
                }
                return m_itemList;
            }
            private set => m_itemList = value;
        }
        public List<int> unsafe_itemList
        {
        	get => m_itemList;
        	set => m_itemList = value;
        }
        public List<long> target
        {
            get
            {
                if(m_target == null)
                {
                    m_target = new();
                }
                return m_target;
            }
            private set => m_target = value;
        }
        public List<long> unsafe_target
        {
        	get => m_target;
        	set => m_target = value;
        }
		
		/*-- constructors --*/
		public GmMailPOD() {}
		public GmMailPOD(int id, string title, string content, string sender, long createTime, long endTime, List<int> itemList, bool isAllPlayer, bool isAllTime, List<long> target, int levelLimit, int payPoint, string channelIds) {
			this.id = id;
			this.title = title;
			this.content = content;
			this.sender = sender;
			this.createTime = createTime;
			this.endTime = endTime;
			this.m_itemList = itemList;
			this.isAllPlayer = isAllPlayer;
			this.isAllTime = isAllTime;
			this.m_target = target;
			this.levelLimit = levelLimit;
			this.payPoint = payPoint;
			this.channelIds = channelIds;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(id);
            _out.Write_string(title);
            _out.Write_string(content);
            _out.Write_string(sender);
            _out.Write_long(createTime);
            _out.Write_long(endTime);
            _out.Write_list_int(m_itemList); 
            _out.Write_boolean(isAllPlayer);
            _out.Write_boolean(isAllTime);
            _out.Write_list_long(m_target); 
            _out.Write_int(levelLimit);
            _out.Write_int(payPoint);
            _out.Write_string(channelIds);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            id = _in.Read_int();
            if(!_in.HasRemaining()) return;
            title = _in.Read_string();
            if(!_in.HasRemaining()) return;
            content = _in.Read_string();
            if(!_in.HasRemaining()) return;
            sender = _in.Read_string();
            if(!_in.HasRemaining()) return;
            createTime = _in.Read_long();
            if(!_in.HasRemaining()) return;
            endTime = _in.Read_long();
            if(!_in.HasRemaining()) return;
            m_itemList = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            isAllPlayer = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            isAllTime = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            m_target = _in.Read_list_long();
            if(!_in.HasRemaining()) return;
            levelLimit = _in.Read_int();
            if(!_in.HasRemaining()) return;
            payPoint = _in.Read_int();
            if(!_in.HasRemaining()) return;
            channelIds = _in.Read_string();
        }
		
		public GmMailPOD Clone() {
            GmMailPOD o = DynamicFactory();
            o.id = id;
            o.title = title;
            o.content = content;
            o.sender = sender;
            o.createTime = createTime;
            o.endTime = endTime;
            if (m_itemList != null) {
                o.m_itemList = new (m_itemList);
            }
            o.isAllPlayer = isAllPlayer;
            o.isAllTime = isAllTime;
            if (m_target != null) {
                o.m_target = new (m_target);
            }
            o.levelLimit = levelLimit;
            o.payPoint = payPoint;
            o.channelIds = channelIds;
            return o;
        }
        
        public void Clear() {
            id = default;
            title = default;
            content = default;
            sender = default;
            createTime = default;
            endTime = default;
            m_itemList = default;
            isAllPlayer = default;
            isAllTime = default;
            m_target = default;
            levelLimit = default;
            payPoint = default;
            channelIds = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "GmMailPOD [";
			str += "id=";
			str += id;
			str += ", title=";
			str += title;
			str += ", content=";
			str += content;
			str += ", sender=";
			str += sender;
			str += ", createTime=";
			str += createTime;
			str += ", endTime=";
			str += endTime;
			str += ", itemList=";
			str += m_itemList.ToString<int>();
			str += ", isAllPlayer=";
			str += isAllPlayer;
			str += ", isAllTime=";
			str += isAllTime;
			str += ", target=";
			str += m_target.ToString<long>();
			str += ", levelLimit=";
			str += levelLimit;
			str += ", payPoint=";
			str += payPoint;
			str += ", channelIds=";
			str += channelIds;
			str += "]";
			return str;
		}
		
	}
}